package com.tf_cut.admin.person.controller;

import com.alibaba.fastjson.JSON;
import com.tf_cut.admin.backend.api.BackEndApi;
import com.tf_cut.admin.common.pojo.PageInfo;
import com.tf_cut.admin.common.pojo.Result;
import com.tf_cut.admin.person.vo.PersonBillAndConsigneeVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;


@RestController
@RequestMapping("/person/bill")
@Slf4j
public class PersonBillController {

    @Autowired
    private BackEndApi personBillApi;

    // 进入商户清单页面
    @GetMapping("list")
    public ModelAndView sellerList() {
        return new ModelAndView("person/bill/list", "personBill", null);
    }

    // 进入新增商户页面
    @GetMapping("sellerinsert")
    public ModelAndView sellerInsert() {
        return new ModelAndView("seller/sellerinsert", "seller", null);
    }

    // 进入新增商户页面
    @GetMapping("sellerimport")
    public ModelAndView sellerImport() {
        return new ModelAndView("seller/sellerimport", "seller", null);
    }

    /**
     * 查询个人发票列表
     *
     * @param personBillAndConsigneeVo
     * @return
     */
    @PostMapping(value = "list/page")
    public Result<PageInfo<PersonBillAndConsigneeVo>> queryPersonBillList(PersonBillAndConsigneeVo personBillAndConsigneeVo) {
        String json = JSON.toJSONString(personBillAndConsigneeVo);
        json = personBillApi.queryPersonBillList(json);
        return Result.of(JSON.parseObject(json, PageInfo.class));
    }

}
